import { ChatStorage } from '../chat/storage';
import { cli } from './cli-manager';
// 对话界面：询问是否继续上次会话
export class SessionSelector {
  private readonly cli = cli

  constructor(private readonly storage: ChatStorage) {}
  // 询问是否继续上次会话
  async selectSession(): Promise<boolean> {
    const hasHistory = await this.storage.hasPreviousSession();
    
    if (!hasHistory) {
      console.log('没有找到历史会话，即将开启新会话');
      return false;
    }
    return new Promise((resolve) => {
      this.cli.interface.question(
        '检测到历史会话，是否继续？(Y/n) ',
        (answer) => {
          resolve(answer.toLowerCase() !== 'n');
        }
      );
    });
  }
}
